import Echarts from "taro-react-echarts";
import * as echarts from "echarts";
import useBaseEchart from "./hooks/useBaseEchart";
import { BaseEchartProps } from "types/BaseEchart";
import styles from "./index.module.scss";
import { View } from "@tarojs/components";
// ! 参考：
// https://github.com/qiuweikangdev/taro-react-echarts
function BaseEchart(props: BaseEchartProps) {
  const { option } = props;
  const baseEchartInst = useBaseEchart(props);

  return (
    <View className={styles["base-echart-wrapper"]}>
      <Echarts
        echarts={echarts}
        option={option}
        ref={baseEchartInst.echartsRef}
      ></Echarts>
    </View>
  );
}

export default BaseEchart;
